home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / bash_114.zip / bash-1.14.2 / support / fixlinks < prev    next >
Text File  |  1994-05-23  |  1KB  |  62 lines

  1. #! /bin/sh
  2. #
  3. # fixlinks - make symlinks in the bash source tree so that there is
  4. #         exactly one version of any given source file.
  5. #
  6. #
  7.  
  8. SRCDIR=.
  9. while [ $# -gt 0 ]; do
  10.     case "$1" in
  11.     -s)    shift; SRCDIR=$1 ;;
  12.     -u)    unfix=yes ;;
  13.     -*)    echo "$0: $1: bad option" 1>&2
  14.         echo "$0: usage: $0 [-u] [-s srcdir] [linkmap]" 1>&2
  15.         exit 1;;
  16.     *)    break ;;
  17.     esac
  18.     shift
  19. done
  20.  
  21. if [ ! -d $SRCDIR/builtins ]; then
  22.     echo "$0: must be run with valid -s argument or from source directory" 1>&2
  23.     exit 1
  24. fi
  25.  
  26. if [ $# -eq 0 ]; then
  27.     linkfile=$SRCDIR/support/SYMLINKS
  28. else
  29.     linkfile=$1    
  30. fi
  31.  
  32. if [ ! -f "$linkfile" ]; then
  33.     echo "$0: symlink map file \`$linkfile' does not exist"
  34.     exit 1
  35. fi
  36.  
  37. rm -f /tmp/z
  38. if (ln -s /dev/null /tmp/z) >/dev/null 2>&1; then
  39.     LN="ln -s"
  40. else
  41.     LN=ln
  42. fi
  43.  
  44. while read name target
  45. do
  46.     case "$name" in
  47.     \#*)    continue;;
  48.     esac
  49.  
  50.     rm -f $name
  51.     case "$unfix" in
  52.     yes)    dirname=`expr "$name" ':' '^\(.*\)/[^/]*'`
  53.         [ -z "$dirname" ] && dirname=.
  54.         cp $dirname/$target $name
  55.         echo $target copied to $name ;;
  56.     *)    $LN $target $name ; echo "$name -> $target" ;;
  57.     esac
  58.  
  59. done < $linkfile
  60.  
  61. exit 0
  62.